package com.gzhuxj201.mapper;

import com.gzhuxj201.entity.Student;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;


@Mapper
public interface StudentMapper {

    List<Student> page(Integer startIdx, Integer pageSize,String sno,String username,Short gender);

    @Insert("insert into student(sno,username,gender,classId,email) values(#{sno},#{username},#{gender},#{classId},#{email})")
    int add(Student student);

    @Select("select * from student where sno=#{sno}")
    Student selectById(String sno);

    int update(Student student);

    int deleteBySnoes(List<Integer> snoes);

    @Select("select * from student where username=#{username} and password=#{password}")
    Student selectByUsernameAndPassword(String username, String password);

    @Select("select * from student where username=#{username}")
    Student selectByUsername(String username);

    @Delete("delete from student where classId=#{classId}")
    int deleteByClassId(Integer classId);

    @Select(
            "SELECT sno,username,email from student where sno in (SELECT sno from sc where cno=#{courseId}) " +
                    "and sno not in (SELECT sno from stufile where homeworkid=#{id})")
    List<Student> selectUnsubmitStu(Integer id, String courseId);
}
